<?php
namespace app\admin\model;
use think\Model;

class CouponModel extends Model
{
	/**
	 * 自动验证
	 */
	protected $validate = [
         'rule' => [
			 'title' => "require|unique:admin|length:6,32",
			 'coupon_price' => "require|length:6,32",
			 'starttime' => "require|length:6,32",
			 'endtime' => "require|length:6,32",
			 'consumption' => "require|length:6,32",
			 'total_num' => "require|length:6,32"
		 ],
         'msg'  => [
			 'title.require' => "请填写优惠券名字",
			 'title.unique' => "优惠券名字已经存在！",
			 'coupon_price.require' => "请填写优惠卷金额",
			 'starttime.require' => "请填写开始时间",
			 'endtime.require' => "请填写截止时间",
			 'consumption.require' => "请填写满多少金额方可使用",
			 'total_num.require' => "请填写优惠券总数量"
		 ]
    ];
	
	/**
	 * 将时间格式自动转为时间戳
	 */
	protected function changeTime($str)
	{
		return strtotime($str);
	}
}